package com.xiaoran.RMQ_1.test9_youxji;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.xiaoran.RMQ_1.utlis.RabbitMqUtils;

import java.util.HashMap;
import java.util.Map;

public class Produce {
    public static final  String QUEUE_NAME="xiaoran";
    public static void main(String args[]) throws Exception{
        //获取信道
        Channel channel=RabbitMqUtils.getChannel();
        Map<String, Object> parims=new HashMap<>();
        parims.put("x-max-priority",10);//官方允许0-255
        channel.queueDeclare(QUEUE_NAME,true,false,false,parims);
        for(int i=0;i<10;i++){
            String message="info"+i;
            if(i==5) {
                AMQP.BasicProperties basicProperties=new AMQP.BasicProperties().builder().priority(5).build();
                channel.basicPublish("",QUEUE_NAME,basicProperties,message.getBytes());
            }else{
                channel.basicPublish("",QUEUE_NAME,null,message.getBytes());
            }
        }
        System.out.println("消息发送完成");
    }
}
